<template>
  <div class="container">
    <!-- 按钮 -->

    <div class="container-button">
      <slot name="button"></slot>
    </div>

    <!-- 表格 -->
    <el-table :data="tableData" border style="width: 100%" class="table">
      <el-table-column v-for="(item,index) in biaotou" :key="index" :fixed="item.fixed" :prop="item.prop" :label="item.label" :width="item.width">
      </el-table-column>
      <slot name="image"></slot>
      <slot name="switch"></slot>

      <el-table-column fixed="right" label="操作" width="100">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="handleEdit(scope.row)" >编辑</el-button>
          <el-button @click="handleClick(scope.row)" type="text" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页器 -->

    <div class="block page">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage4" :page-sizes="[100, 200, 300, 400]" :page-size="100" layout="total, sizes, prev, pager, next, jumper" :total="400">
      </el-pagination>
    </div>
  </div>
</template>



<script>
export default {
  components: {},
  props: { tableData: Array, biaotou: Array },
  data() {
    return {
      serach: '',
      currentPage1: 5,
      currentPage2: 5,
      currentPage3: 5,
      currentPage4: 4
    }
  },
  created() {},
  mounted() {},
  methods: {
    // 查看当前行数据
    handleClick(row) {
      console.log(row)
      
      this.$emit('rowClick', row)
    },

    handleEdit(row){
      this.$emit('handleEdited',row)

    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
    }
  },
  watch: {},
  computed: {}
}
</script>

<style lang="scss" scoped>
.container {
  padding: 20px;
}
.container-button {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}
.table {
  margin-bottom: 20px;
}
.page {
  display: flex;
  justify-content: flex-end;
}
</style>
